package com.fancy.projecty.B_流程实例;


import com.fancy.projecty.util.CeuiUtils;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Arrays;
import java.util.List;

/**
 * 删除流程实例
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class A_删除流程实例 {
	/**
	 * 被删除的流程信息保存在 act_hi_procinst 历史流程实例表
	 */
	@Test
	public void c_删除流程实例() {
		/**
		 * 参数1 ,流程实例id (processInstanceId)
		 * 参数2 ,删除原因
		 */
		runtimeService.deleteProcessInstance("180001", "删除原因");//删除流程
	}

	/**
	 * 批量删除流程实例
	 */
	@Test
	public void c_批量删除流程实例() {
		List<String> strings = Arrays.asList("170019", "172508", "175001", "175008", "175015");
		for (String string : strings) {
			runtimeService.deleteProcessInstance(string, "删除原因");//删除流程
		}
	}


	@Autowired
	/*执行管理、包括启动、推进、删除流程实例等操作*/
	private RuntimeService runtimeService;


	@Autowired
	/*任务管理,可以做任务的查询的*/
	private TaskService taskService;

	@Autowired
	/*管理流程定义,部署相关的Service*/
	private RepositoryService repositoryService;
}
